package com.gxa.xly2024.service.impl;

import com.gxa.xly2024.mapper.EmployeeMapper;
import com.gxa.xly2024.pojo.Employee;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class EmployeeServiceImpl {


    @Resource
    private EmployeeMapper employeeMapper;


    public Map<String, Object> selectEmployee() {
        List<Employee> employee = this.employeeMapper.selectEmployee();
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);//查询layui默认0为正确
        map.put("msg", "查询id成功");
        map.put("data", employee);
        return map;
    }


    public Map<String, Object> insert(Employee employee) {
        this.employeeMapper.insert(employee);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "新增用户成功");
        map.put("data", employee);
        return map;
    }

    public Map<String, Object> updateById(Employee employee) {
        this.employeeMapper.updateById(employee);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "更新用户成功");
        map.put("data", employee);
        return map;
    }

    public Map<String, Object> deleteById(Integer id) {
        this.employeeMapper.deleteById(id);
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "删除用户成功");
        map.put("id", id);
        return map;
    }
}
